package com.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;


@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {
    /**
     * 商品图片介绍
     *
     * @param
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String path = "/images/ims/";
        File file = new File(path);
        File[] ts = file.listFiles();
        if (ts != null) {
            for (File tse : ts) {
                String Code = tse + "";
                String paths = Code.substring(path.length());
                registry.addResourceHandler("/images/" + paths + "/封面/**").addResourceLocations("file:" + path + paths + "/封面/");
                registry.addResourceHandler("/images/" + paths + "/详情介绍/**").addResourceLocations("file:" + path + paths + "/详情介绍/");
                registry.addResourceHandler("/images/" + paths + "/轮播图/**").addResourceLocations("file:" + path + paths + "/轮播图/");
            }
        }


//        registry.addResourceHandler("/images/**").addResourceLocations("file:/images/ims/")
//        ;
////        registry.addResourceHandler("/images/**").addResourceLocations("file:\\D:\\图片\\刘新月\\");

    }


}